package cn.shiwei.hr.web.controller;

import cn.shiwei.hr.doc.CourseDoc;
import cn.shiwei.hr.dto.CourseLisSearchtDTO;
import cn.shiwei.hr.repository.AjaxResult;
import cn.shiwei.hr.service.ISearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/search")
public class SearchController {

    @Autowired
    private ISearchService searchService;

    @PutMapping("/save")
    public AjaxResult saveCourse(@RequestBody CourseDoc doc){
        searchService.saveCourse(doc);
        return AjaxResult.me();
    };

    @DeleteMapping("/del")
    public AjaxResult deleteCourseById(@RequestParam("id") Long id){
        searchService.deleteCourse(id);
        return AjaxResult.me();
    }

    @PostMapping("/searchCourse")
    public AjaxResult searchCourse(@RequestBody CourseLisSearchtDTO queryParams){

        return AjaxResult.me().setResultObj(searchService.searchCourse(queryParams));
    }
}
